<template>
  <div class="preAudit-record">
    <Form
      ref="form"
      layoutType="grid"
      :optionList="reCordFormRow"
      :defaultModel="defaultValue"
      @btnHandler="btnHandler"
    ></Form>
    <Tip
      :tip="tip"
      bcgColor="rgba(45, 90, 203, 0.09)"
      :icon="false"
      fontColor="#2D5ACB"
      class="record-tip"
    ></Tip>
    <MarketDemand
      class="record-table"
      :tableList="tableList"
      :headerList="headerList"
      :serialSpan="headerList[0].span"
      :total="total"
      @pageChange="pageChange"
      :pageNum="customOtherOpt.pagination.pageNum"
      columnName="company"
      time="code"
    ></MarketDemand>
  </div>
</template>

<script>
import Form from '@/views/backstageSupport/components/formTable/form.vue'
import Tip from '@/views/backstageSupport/components/common/tip.vue'
import { reCordFormRow } from './config.js'
import MarketDemand from '@/components/common/MarketDemand'
import { getAgecyList } from '@/api/dataAnalysis'
import mixinsBackStack from '@/views/backstageSupport/mixins'

export default {
  mixins: [mixinsBackStack],
  data() {
    return {
      reCordFormRow,
      defaultSearchParam: {},
      defaultValue: {},
      tableList: [],
      total: 0,
      customOtherOpt: {
        pagination: {
          total: 0,
          pageNum: 1,
          pageSize: 10
        }
      },
      headerList: [
        {
          thName: '序号',
          span: 5
        },
        {
          thName: '代理机构名称',
          span: 14
        },
        {
          thName: '代理机构代码',
          span: 5
        }
      ]
    }
  },
  components: {
    Form,
    Tip,
    MarketDemand
  },
  mounted() {
    this.initTableValue()
  },
  computed: {
    tip() {
      return `符合筛选要求的代理机构，共${this.total}计家`
    }
  },
  methods: {
    async initTableValue() {
      const params = {
        pageNum: this.customOtherOpt.pagination.pageNum,
        pageSize: this.customOtherOpt.pagination.pageSize
      }
      const { rows, total } = await getAgecyList({ ...params, ...this.searchParam })
      this.tableList = rows
      this.total = total
    },
    pageChange(e) {
      this.customOtherOpt.pagination.pageNum = e
      this.initTableValue()
    }
  },
}
</script>